package com.css.fxfzysx.modules.vulnerabilityStatistics.service.impl;

import com.css.fxfzysx.base.response.RestResponse;
import com.css.fxfzysx.modules.cztDataMange.repository.BacInformationRepository;
import com.css.fxfzysx.modules.cztDataMange.repository.DomeFacilitiesRepository;
import com.css.fxfzysx.modules.lifeline.repository.LifelineRepository;
import com.css.fxfzysx.modules.vaomeFacilities.repository.VmeFacilitiesRepository;
import com.css.fxfzysx.modules.vulnerabilityStatistics.service.VulStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class VulStatisticsServiceImpl implements VulStatisticsService {
    @Autowired
    private BacInformationRepository bacInformationRepository;
    @Autowired
    private VmeFacilitiesRepository vmeFacilitiesRepository;
    @Autowired
    private DomeFacilitiesRepository domeFacilitiesRepository;

    @Autowired
    private LifelineRepository lifelineRepository;

    @Override
    public RestResponse statistics(String province) {
        Map<String,Object> map=new HashMap<>();
        int buildingAreaCount=0;
        int majorProject=0;
        int lifeLineCount=0;
        buildingAreaCount+=bacInformationRepository.getBuildingDataByProvince(province);
        buildingAreaCount+=bacInformationRepository.getBrickDataByProvince(province);
        buildingAreaCount+=bacInformationRepository.getConcreteDataByProvince(province);
        buildingAreaCount+=bacInformationRepository.getHighDataByProvince(province);
        //buildingAreaCount+=bacInformationRepository.getProbabilityDataByProvince(province);
        buildingAreaCount+=bacInformationRepository.getBuildingHistoryDataByProvince(province);

        //majorProject+=vmeFacilitiesRepository.getDateByProvince(province);
        majorProject+=domeFacilitiesRepository.getMajorProjectDataByProvince(province);
        majorProject+=domeFacilitiesRepository.getReserviorDataByProvince(province);



        lifeLineCount+=lifelineRepository.getPipeNetworkDataByProvince(province);
        lifeLineCount+=lifelineRepository.getWaterworksDataByProvince(province);
        lifeLineCount+=lifelineRepository.getPoolDataByProvince(province);
        int airReceiverCount = lifelineRepository.getAirReceiverDataByProvince(province);
        majorProject+=airReceiverCount;
        lifeLineCount+=airReceiverCount;
        lifeLineCount+=lifelineRepository.getBridgeDataByProvince(province);
        lifeLineCount+=lifelineRepository.getRoadDataByProvince(province);
        lifeLineCount+=lifelineRepository.getTransformerSubstationDataByProvince(province);
        lifeLineCount+=lifelineRepository.getOverheadLineDataByProvince(province);
        lifeLineCount+=lifelineRepository.getCableRouteDataByProvince(province);
        lifeLineCount+=lifelineRepository.getImportantPowerhouseDataByProvince(province);
        lifeLineCount+=lifelineRepository.getCommIndoorEquipmentDataByProvince(province);
        lifeLineCount+=lifelineRepository.getTvTowerDataByProvince(province);
        map.put("buildingAreaCount",buildingAreaCount);
        map.put("majorProject",majorProject);
        map.put("lifeLineCount",lifeLineCount);
        return RestResponse.succeed(map);
    }
}
